<?php

//<editor-fold defaultstate="collapsed" desc="License & Copyright">
/*
 * @license
 */

/**
 *
 * @author Jevgeni Geimanen (jevgeni.geimanen@gmail.com)
 */
//</editor-fold>
class ComponentCollection extends SCCollection implements ArrayAccess{
    
    //<editor-fold defaultstate="collapsed" desc="ParentControl">
    /**
     * @var Container
     */
    private $_ParentControl = null;

    /**
     *
     * @return Container
     */
    public function getParentControl() {
        return $this->_ParentControl;
    }

    /**
     *
     * @param Container $parent
     * @return ParentControl 
     */
    public function setParentControl($parent) {
        $this->_ParentControl = $parent;
        return $this;
    }

    //</editor-fold>
    
    /**
     *
     * @param Component $element 
     * @return Component
     */
    public function Add($element) {
        $element->setParentControl($this->getParentControl())->Init();
        $this->_array_content[$element->getControlName()] = $element;
        return parent::Add($element);
    }
    
    /**
     *
     * @return ComponentCollection 
     */
    public function Create() {
        foreach ($this as $uid=>$control) $control->Create();
        return $this;
    }
    //<editor-fold defaultstate="collapsed" desc="Interface::ArrayAccess">
    protected $_array_content = array();

    /**
     * @return boolean 
     */
    public function offsetExists($offset) {
        return isset($this->_array_content[$offset]);
    }

    /**
     * 
     */
    public function offsetGet($offset) {
        return $this->_array_content[$offset];
    }

    /**
     * @return void
     */
    public function offsetSet($offset, $value) {
        throw new Exception("Not implemented");
    }

    /**
     * @return void 
     */
    public function offsetUnset($offset) {
        throw new Exception("Not implemented");
    }

    //</editor-fold>
}

?>
